﻿using MatTrace.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using MatTrace.Inputs;

namespace MatTrace
{


    /// <summary>
    /// Ef扩展Repository
    /// </summary>
    public class Tmrbr001Repository : EfCoreRepository<MatTraceDbContext, Tmrbr001,Guid>, ITmrbr001Repository
    {

        public Tmrbr001Repository(IDbContextProvider<MatTraceDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }

        public async Task<bool> Exist_MatNo(string MatNo)
        {
            return  await   this.DbContext.Tmrbr001.Where(m=>m.MatNo==MatNo).CountAsync()>0?true: false;
        }

        public async Task<bool> Exist_MatNoStatus(string MatNo,string Status)
        {
            return await this.DbContext.Tmrbr001.Where(m => m.MatNo == MatNo&&m.MatStatus== Status).CountAsync() > 0 ? true : false;
        }

        public  Task<List<Tmrbr001>>  GetTmrbr001ConfirmPlan(QueryTmrbr001Input queryTmrbr001Input)
        {
            return    this.DbContext.Tmrbr001.
                //WhereIf(!string.IsNullOrEmpty(queryTmrbr001Input.MatNo), m => m.MatNo == queryTmrbr001Input.MatNo).
                //WhereIf(!string.IsNullOrEmpty(queryTmrbr001Input.OrderNo), m => m.OrderNo == queryTmrbr001Input.OrderNo).
                //WhereIf(!string.IsNullOrEmpty(queryTmrbr001Input.StockNo), m => m.StockNo == queryTmrbr001Input.StockNo).
                Where(m=>m.MatStatus=="33").ToListAsync();
              
        }
    }
}
